home *** CD-ROM | disk | FTP | other *** search
/ Acorn User: China / Acorn User China CD-ROM (UK) (Disc A) / Acorn User China CD-ROM (UK) (Disc A).bin / DEMON / DEVELOPER / HYPERMAIL.ARC / !hypermail_c_print < prev    next >
Encoding:
Text File  |  1996-01-25  |  38.3 KB  |  1,220 lines

  1. /*
  2. ** Copyright (C) 1994, Enterprise Integration Technologies Corp.        
  3. ** All Rights Reserved.
  4. ** Kevin Hughes, kevinh@eit.com 
  5. ** 7/31/94
  6. */
  7.  
  8. #include "hypermail.h"
  9. #include "print.h"
  10.  
  11. #ifdef RISCOS
  12.   #include "OS:osfile.h"
  13. #endif
  14.  
  15.  
  16. /* Printing...the other main part of this program!
  17. ** This writes out the articles, beginning with the number startnum.
  18. */
  19.  
  20.  
  21. void writearticles(dir, label, overwrite, startnum)
  22.  
  23.      char *dir;
  24.      char *label;
  25.      int overwrite;
  26.      int startnum;
  27. {
  28.         int num, tmpnum, statusnum, skip, subjmatch, newfile;
  29.         char name[NAMESTRLEN], email[MAILSTRLEN], subject[SUBJSTRLEN],
  30.                 inreply[REPYSTRLEN], date[DATESTRLEN], fromdate[DATESTRLEN],
  31.                 msgid[MSGDSTRLEN];
  32.         char currentemail[MAILSTRLEN], currentid[MSGDSTRLEN],
  33.                 currentsubject[SUBJSTRLEN];
  34.         char name2[NAMESTRLEN], email2[MAILSTRLEN], subject2[SUBJSTRLEN],
  35.                 inreply2[REPYSTRLEN], date2[DATESTRLEN], fromdate2[DATESTRLEN],
  36.                 msgid2[MSGDSTRLEN];
  37.         char filename[MAXFILELEN];
  38.  
  39.         #ifdef RISCOS
  40.           char directoryname[MAXFILELEN];
  41.         #endif
  42.  
  43.         struct body *bp, *status;
  44.         struct reply *rp;
  45.         FILE *fp;
  46.  
  47.         num = startnum;
  48.         skip = 0;
  49.  
  50.         if (showprogress)
  51.                 printf("Writing articles to \"%s\"...    ", dir);
  52.  
  53.         while ((bp = (struct body *) hashnumlookup(num, name, email,
  54.         subject, inreply, date, fromdate, msgid)) != NULL) {
  55.  
  56.                 strcpy(currentemail, email);
  57.                 strcpy(currentid, msgid);
  58.                 strcpy(currentsubject, subject);
  59.  
  60.        #ifdef RISCOS
  61.  
  62.                 sprintf(directoryname, "%s.%.4d", dir,num/FPD);
  63.                 sprintf(filename, "%s.%.4d", directoryname,num);
  64.  
  65.                 osfile_create_dir (directoryname,0);
  66.  
  67.        #else
  68.  
  69.                 sprintf(filename, "%s%s%.4d.html", dir,
  70.                 (dir[strlen(dir) - 1] == '/') ? "" : "/", num);
  71.  
  72.        #endif
  73.  
  74.  
  75.  
  76. /* Determine to overwrite files or not
  77. */
  78.                 if (isfile(filename))
  79.                         newfile = 0;
  80.                 else
  81.                         newfile = 1;
  82.  
  83.                 if (!newfile && !overwrite) {
  84.                         skip = 1;
  85.                         num++;
  86.                         continue;
  87.                 }
  88.                 else {
  89.                         if ((fp = fopen(filename, "w")) == NULL) {
  90.                                 sprintf(errmsg, "Couldn't write \"%s\".",
  91.                                 filename);
  92.                                 progerr(NULL);
  93.                         }
  94.                 }
  95.  
  96. /* Create the comment fields necessary for incremental updating
  97. */
  98.  
  99.                 printcomment(fp, "received", fromdate);
  100.                 printcomment(fp, "sent", date);
  101.                 printcomment(fp, "name", name);
  102.                 printcomment(fp, "email", email);
  103.                 printcomment(fp, "subject", convchars(subject));
  104.                 printcomment(fp, "id", msgid);
  105.                 printcomment(fp, "inreplyto", convchars(inreply));
  106.  
  107.                 fprintf(fp, "<title>%s: %s</title>\n", label,
  108.                 convchars(subject));
  109.                 fprintf(fp, "<h1>%s</h1>\n", convchars(subject));
  110.                 if (!strcmp(name, email)) {
  111. #ifdef MAILCOMMAND
  112.                         fprintf(fp, "<a href=\"%s\">",
  113.                         makemailcommand(MAILCOMMAND, email, currentid,
  114.                         currentsubject));
  115.                         fprintf(fp, "<i>%s</i></a><br>\n", name);
  116. #else
  117.                         fprintf(fp, "<i>%s</i><br>\n", name);
  118. #endif
  119.                 }
  120.                 else {
  121. #ifdef MAILCOMMAND
  122.                         fprintf(fp, "<b>%s</b> (<a href=\"%s\">", name,
  123.                         makemailcommand(MAILCOMMAND, email, currentid, 
  124.                         currentsubject));
  125.                         fprintf(fp, "<i>%s</i></a>)<br>\n", email);
  126. #else
  127.                         fprintf(fp, "%s (<i>%s</i>)<br>\n", name, email);
  128. #endif
  129.                 }
  130.                 fprintf(fp, "<i>%s</i>\n<p>\n", date);
  131.  
  132.                 fprintf(fp, "<ul>\n");
  133.  
  134.                 fprintf(fp, "<li> <b>Messages sorted by:</b> ");
  135.  
  136. #ifdef RISCOS
  137.  
  138.                 fprintf(fp, "<a href=\"file://%s/%s/%s#%d\">[ date ]</a>",HOST,INDEXDIR , datename, num);
  139.                 fprintf(fp, "<a href=\"file://%s/%s/%s#%d\">[ thread ]</a>", HOST,INDEXDIR, thrdname,  num);
  140.                 fprintf(fp, "<a href=\"file://%s/%s/%s#%d\">[ subject ]</a>", HOST,INDEXDIR, subjname,  num);
  141.                 fprintf(fp, "<a href=\"file://%s/%s/%s#%d\">[ author ]</a>\n", HOST,INDEXDIR, authname,  num);
  142.  
  143. #else
  144.                 fprintf(fp, "<a href=\"%s#%d\">[ date ]</a>", datename, num);
  145.                 fprintf(fp, "<a href=\"%s#%d\">[ thread ]</a>", thrdname, num);
  146.                 fprintf(fp, "<a href=\"%s#%d\">[ subject ]</a>", subjname, num);
  147.                 fprintf(fp, "<a href=\"%s#%d\">[ author ]</a>\n", authname,
  148.                 num);
  149. #endif
  150.  
  151.                 printcomment(fp, "next", "start");
  152.  
  153. /* Is there a next message?
  154. */
  155.  
  156.                 status = (struct body *) hashnumlookup(num + 1, name2,
  157.                 email2, subject2, inreply2, date2, fromdate2, msgid2);
  158.                 if (status != NULL) {
  159.                         fprintf(fp, "<li> <b>Next message:</b> ");
  160. #ifdef RISCOS
  161.  
  162.                         fprintf(fp, "<a href=\"file://%s/%s/%.4d/%.4d\">%s: \"%s\"</a>\n",
  163.                         HOST, FILEDIR, (num + 1)/FPD, num + 1, name2, convchars(subject2));
  164.  
  165. #else
  166.  
  167.                         fprintf(fp, "<a href=\"%.4d.html\">%s: \"%s\"</a>\n",
  168.                         num + 1, name2, convchars(subject2));
  169. #endif
  170.                 }
  171.  
  172. /* Is there a previous message?
  173. */
  174.  
  175.                 status = (struct body *) hashnumlookup(num - 1, name2,
  176.                 email2, subject2, inreply2, date2, fromdate2, msgid2);
  177.                 if (status != NULL) {
  178.                         fprintf(fp, "<li> <b>Previous message:</b> ");
  179. #ifdef RISCOS
  180.  
  181.                         fprintf(fp, "<a href=\"file://%s/%s/%.4d/%.4d\">%s: \"%s\"</a>\n",
  182.                         HOST, FILEDIR, (num -1)/FPD, num - 1, name2, convchars(subject2));
  183.  
  184.  
  185. #else
  186.  
  187.                         fprintf(fp, "<a href=\"%.4d.html\">%s: \"%s\"</a>\n",
  188.                         num - 1, name2, convchars(subject2));
  189. #endif
  190.                 }
  191.  
  192. /* Is this message a reply to another?
  193. */
  194.  
  195.                 if (inreply[0] != '\0') {
  196.                         statusnum = hashreplylookup(inreply, name, subject,
  197.                         &subjmatch);
  198.                         if (statusnum != -1) {
  199.                                 if (subjmatch)
  200.                                         fprintf(fp,
  201.                                         "<li> <b>Maybe in reply to:</b>");
  202.                                 else
  203.                                         fprintf(fp,
  204.                                         "<li> <b>In reply to:</b>");
  205.  
  206. #ifdef RISCOS
  207.  
  208.                                 fprintf(fp, " <a href=\"file://%s/%s/%.4d/%.4d\">",
  209.                                 HOST, FILEDIR, statusnum/FPD, statusnum);
  210.  
  211. #else
  212.  
  213.                                 fprintf(fp, " <a href=\"%.4d.html\">",
  214.                                 statusnum);
  215.  
  216. #endif
  217.  
  218.                                 fprintf(fp, "%s: \"%s\"</a>\n",
  219.                                 name, convchars(subject));
  220.                         }
  221.                 }
  222.  
  223. /* Is there a message next in the thread?
  224. */
  225.  
  226.                 printcomment(fp, "nextthread", "start");
  227.  
  228.                 for (rp = threadlist; rp != NULL; rp = rp->next)
  229.                         if (rp->msgnum == num && rp->next != NULL &&
  230.                         rp->next->msgnum != -1) {
  231.                                 fprintf(fp, "<li> <b>Next in thread:</b> ");
  232. #ifdef RISCOS
  233.  
  234.                                fprintf(fp, "<a href=\"file://%s/%s/%.4d/%.4d\">",
  235.                                HOST, FILEDIR, (rp->next->msgnum)/FPD,
  236.                                rp->next->msgnum);
  237.  
  238. #else
  239.  
  240.                                 fprintf(fp, "<a href=\"%.4d.html\">",
  241.                                 rp->next->msgnum);
  242. #endif
  243.  
  244.  
  245.                                 fprintf(fp, "%s: \"%s\"</a>\n",
  246.                                 rp->next->name, convchars(rp->next->subject));
  247.                         }
  248.  
  249. /* Does this message have replies? If so, print them all!
  250. */
  251.  
  252. #ifdef SHOWREPLIES
  253.                 for (rp = replylist; rp != NULL; rp = rp->next)
  254.                         if (rp->msgnum == num) {
  255.                                 if (rp->maybereply)
  256.                                         fprintf(fp, "<li> <b>Maybe reply:</b>");
  257.                                 else
  258.                                         fprintf(fp, "<li> <b>Reply:</b>");
  259.  
  260.    #ifdef RISCOS
  261.  
  262.                                 fprintf(fp, " <a href=\"file://%s/%s/%.4d/%.4d\">",
  263.                                 HOST, FILEDIR, (rp->frommsgnum)/FPD,
  264.                                 rp->frommsgnum);
  265.  
  266.    #else
  267.                                 fprintf(fp, " <a href=\"%.4d.html\">",
  268.                                 rp->frommsgnum);
  269.    #endif
  270.  
  271.                                 fprintf(fp, "%s: \"%s\"</a>\n",
  272.                                 rp->name, convchars(rp->subject));
  273.                         }
  274.                 printcomment(fp, "reply", "end");
  275. #endif
  276.  
  277.                 fprintf(fp, "</ul>\n");
  278.  
  279. /* Finally...print the body!
  280. */
  281.                 printbody(fp, bp, currentid, currentsubject);
  282.  
  283.                 fprintf(fp, "<p>\n<ul>\n");
  284.  
  285.                 printcomment(fp, "next", "start");
  286.  
  287.                 status = (struct body *) hashnumlookup(num + 1, name2,
  288.                 email2, subject2, inreply2, date2, fromdate2, msgid2);
  289.                 if (status != NULL) {
  290.                         fprintf(fp, "<li> <b>Next message:</b> ");
  291.  
  292. #ifdef RISCOS
  293.  
  294.                         fprintf(fp, "<a href=\"file://%s/%s/%.4d/%.4d.html\">%s: \"%s\"</a>\n",
  295.                         HOST, FILEDIR, (num + 1)/FPD, num + 1, name2, convchars(subject2));
  296.  
  297. #else
  298.  
  299.                         fprintf(fp, "<a href=\"%.4d.html\">%s: \"%s\"</a>\n",
  300.                         num + 1, name2, convchars(subject2));
  301. #endif
  302.                 }
  303.  
  304.                 status = (struct body *) hashnumlookup(num - 1, name2,
  305.                 email2, subject2, inreply2, date2, fromdate2, msgid2);
  306.                 if (status != NULL) {
  307.                         fprintf(fp, "<li> <b>Previous message:</b> ");
  308.  
  309. #ifdef RISCOS
  310.  
  311.                         fprintf(fp, "<a href=\"file://%s/%s/%.4d/%.4d\">%s: \"%s\"</a>\n",
  312.                         HOST, FILEDIR, (num -1)/FPD, num - 1, name2, convchars(subject2));
  313.  
  314. #else
  315.  
  316.                         fprintf(fp, "<a href=\"%.4d.html\">%s: \"%s\"</a>\n",
  317.                         num - 1, name2, convchars(subject2));
  318. #endif
  319.                 }
  320.  
  321.                 if (inreply[0] != '\0') {
  322.                         statusnum = hashreplylookup(inreply, name, subject,
  323.                         &subjmatch);
  324.                         if (statusnum != -1) {
  325.                                 if (subjmatch)
  326.                                         fprintf(fp,
  327.                                         "<li> <b>Maybe in reply to:</b>");
  328.                                 else
  329.                                         fprintf(fp,
  330.                                         "<li> <b>In reply to:</b>");
  331.  
  332. #ifdef RISCOS
  333.  
  334.                                 fprintf(fp, " <a href=\"file://%s/%s/%.4d/%.4d\">",
  335.                                 HOST, FILEDIR, statusnum/FPD, statusnum);
  336.  
  337. #else
  338.  
  339.                                 fprintf(fp, " <a href=\"%.4d.html\">",
  340.                                 statusnum);
  341. #endif
  342.  
  343.  
  344.                                 fprintf(fp, "%s: \"%s\"</a>\n",
  345.                                 name, convchars(subject));
  346.                         }
  347.                 }
  348.  
  349.                 printcomment(fp, "nextthread", "start");
  350.  
  351.                 for (rp = threadlist; rp != NULL; rp = rp->next)
  352.                         if (rp->msgnum == num && rp->next != NULL &&
  353.                         rp->next->msgnum != -1) {
  354.                                 fprintf(fp, "<li> <b>Next in thread:</b> ");
  355.  
  356. #ifdef RISCOS
  357.  
  358.                                 fprintf(fp, "<a href=\"file://%s/%s/%.4d/%.4d\">",
  359.                                 HOST, FILEDIR, (rp->next->msgnum)/FPD,
  360.                                 rp->next->msgnum);
  361.  
  362. #else
  363.  
  364.                                 fprintf(fp, "<a href=\"%.4d.html\">",
  365.                                 rp->next->msgnum);
  366. #endif
  367.                                 fprintf(fp, "%s: \"%s\"</a>\n",
  368.                                 rp->next->name, convchars(rp->next->subject));
  369.                         }
  370.  
  371. #ifdef SHOWREPLIES
  372.                 for (rp = replylist; rp != NULL; rp = rp->next)
  373.                         if (rp->msgnum == num) {
  374.                                 if (rp->maybereply)
  375.                                         fprintf(fp, "<li> <b>Maybe reply:</b>");
  376.                                 else
  377.                                         fprintf(fp, "<li> <b>Reply:</b>");
  378.  
  379.    #ifdef RISCOS
  380.  
  381.                                 fprintf(fp, " <a href=\"file://%s/%s/%.4d/%.4d\">",
  382.                                 HOST, FILEDIR,  rp->frommsgnum/FPD, 
  383.                                 rp->frommsgnum);
  384.  
  385.    #else
  386.  
  387.                                 fprintf(fp, " <a href=\"%.4d.html\">",
  388.                                 rp->frommsgnum);
  389.    #endif
  390.  
  391.                                 fprintf(fp, "%s: \"%s\"</a>\n",
  392.                                 rp->name, convchars(rp->subject));
  393.                         }
  394.                 printcomment(fp, "reply", "end");
  395. #endif
  396.  
  397.                 fprintf(fp, "</ul>\n");
  398.  
  399.                 fclose(fp);
  400.  
  401.  
  402.                 if (newfile && chmod(filename, filemode) == -1) {
  403.                         sprintf(errmsg, "Couldn't chmod \"%s\" to %o.",
  404.                         filename, filemode);
  405.                         progerr(NULL);
  406.                 }
  407.  
  408.                 if (!(num % 5) && showprogress && !skip) {
  409.  
  410. #ifdef RISCOS
  411.  
  412.                         printf("%3.0f%c", ((float) num / (float) bignum)
  413.                         * 100, '%');
  414. #else
  415.                         printf("\b\b\b\b%3.0f%c", ((float) num / (float) bignum)
  416.                         * 100, '%');
  417. #endif
  418.  
  419.                           fflush(stdout);
  420.                 }
  421.  
  422. #ifdef RISCOS
  423.     osfile_set_type (filename,FILETYPE);
  424. #endif
  425.  
  426.  
  427.                 num++;
  428.         }
  429.         if (showprogress)
  430.  
  431. #ifdef RISCOS
  432.  
  433.                printf("\n");
  434. #else
  435.                printf("\b\b\b\b    \n");
  436. #endif
  437.  
  438.         if (!overwrite)
  439.                 bignum = num - 1;
  440.  
  441.  
  442. }                                        
  443.  
  444. void printbody(fp, bp, id, subject)
  445.      FILE *fp;
  446.      struct body *bp;
  447.      char *id;
  448.      char *subject;
  449. {
  450.  
  451.         int inheader, insig, inblank, inhtml;
  452.  
  453. #ifdef SHOWHR
  454.         fprintf(fp, "<hr>\n");
  455. #endif
  456.         printcomment(fp, "body", "start");
  457.  
  458.         if (!showhtml || (showhtml && showheaders))
  459.                 fprintf(fp, "<pre>\n");
  460.  
  461.         inheader = 1;
  462.         inblank = 1;
  463.         inhtml = 0;
  464.         insig = 0;
  465.  
  466.         while (bp != NULL) {
  467.  
  468.                 if ((bp->line)[0] == '\n') {
  469.                         if (inheader && showhtml && showheaders)
  470.                                 fprintf(fp, "</pre>\n");
  471.                         inheader = 0;
  472.                 }
  473.                 else if (inheader && !showheaders) {
  474.                         bp = bp->next;
  475.                         continue;
  476.                 }
  477.  
  478.                 if ((bp->line)[0] == '\n' && inblank) {
  479.                         bp = bp->next;
  480.                         continue;
  481.                 }
  482.                 else
  483.                         inblank = 0;
  484.  
  485.                 if (!strncmp(bp->line, "<html>", 6) ||
  486.                 !strncmp(bp->line, "<HTML>", 6)) {
  487.                         inhtml = 1;
  488.                         if (!showhtml)
  489.                                 fprintf(fp, "</pre>\n");
  490.                 }
  491.                 else if (!strncmp(bp->line, "</html>", 7) ||
  492.                 !strncmp(bp->line, "</HTML>", 7)) {
  493.                         inhtml = 0;
  494.                         fprintf(fp, "%s", bp->line);
  495.                         if (!showhtml)
  496.                                 fprintf(fp, "<pre>\n");
  497.                         bp = bp->next;
  498.                         continue;
  499.                 }
  500.  
  501.                 if (inhtml) {
  502.                         fprintf(fp, "%s", bp->line);
  503.                         bp = bp->next;
  504.                         continue;
  505.                 }
  506.  
  507.                 if (showhtml) {
  508.                         if (!strcmp(bp->line, "--\n") ||
  509.                         !strcmp(bp->line, "-- \n") ||
  510.                         !strcmp(bp->line, "---\n")) {
  511.                                 insig = 1;
  512.                                 fprintf(fp, "<pre>\n");
  513.                         }
  514.  
  515.                         if ((bp->line)[0] == '\n')
  516.                                 fprintf(fp, "<p>\n");
  517.                         else {
  518.                                 if (insig)
  519.                                         fprintf(fp, "%s",
  520.                                         (char *) convurls(bp->line,
  521.                                         id, subject));
  522.                                 else if (isquote(bp->line))
  523. #ifdef IQUOTES
  524.                                         fprintf(fp, "<i>%s</i><br>\n",
  525.                                         (char *) convurls(rmcr(bp->line),
  526.                                         id, subject));
  527. #else
  528.                                         fprintf(fp, "%s<br>\n",
  529.                                         (char *) convurls(rmcr(bp->line),
  530.                                         id, subject));
  531. #endif
  532.                                 else if ((bp->line)[0] != '\0')
  533. #ifdef SHOWBR
  534.                                         fprintf(fp, "%s<br>\n",
  535.                                         (char *) convurls(rmcr(bp->line),
  536.                                         id, subject));
  537. #else
  538.                                         fprintf(fp, "%s\n",
  539.                                         (char *) convurls(rmcr(bp->line),
  540.                                         id, subject));
  541. #endif
  542.                         }
  543.                 }
  544.                 else if ((bp->line)[0] != '\0')
  545.                         fprintf(fp, "%s", (char *) convurls(bp->line,
  546.                         id, subject));
  547.  
  548.                 bp = bp->next;
  549.  
  550.         }
  551.  
  552.         if (!showhtml)
  553.                 fprintf(fp, "</pre>\n");
  554.         else {
  555.                 if (insig)
  556.                         fprintf(fp, "</pre>\n");
  557.         }
  558.  
  559.         printcomment(fp, "body", "end");
  560. #ifdef SHOWHR
  561.         fprintf(fp, "<hr>\n");
  562. #endif
  563. }
  564.  
  565. /* Write the date index...
  566. */
  567.  
  568. void writedates(dir, label, archives, about)
  569.      char *dir;
  570.      char *label;
  571.      char *archives;
  572.      char *about;
  573. {
  574.         int num, newfile;
  575.         char name[NAMESTRLEN], email[MAILSTRLEN], subject[SUBJSTRLEN],
  576.                 inreply[REPYSTRLEN];
  577.         char filename[MAXFILELEN];
  578.         struct body *bp, *status;
  579.         FILE *fp;
  580.  
  581. #ifdef RISCOS
  582.         sprintf(filename, "%s.%s", INDEXDIR,datename);
  583. #else
  584.  
  585.         sprintf(filename, "%s%s%s", dir,".","date");
  586.         (dir[strlen(dir) - 1] == '/') ? "" : "/", datename);
  587. #endif
  588.  
  589.  
  590.         if (isfile(filename))
  591.                 newfile = 0;
  592.         else
  593.                 newfile = 1;
  594.         if ((fp = fopen(filename, "w")) == NULL) {
  595.                 sprintf(errmsg, "Couldn't write \"%s\".", filename);
  596.                 progerr(NULL);
  597.         }
  598.  
  599.  
  600.         if (showprogress)
  601.  
  602.                 printf("Writing date index to \"%s\"...", filename);
  603.  
  604.  
  605.         fprintf(fp, "<title>%s by date</title>\n", label);
  606.         fprintf(fp, "<a name=\"start\"><h1>%s by date</h1></a>\n", label);
  607.         fprintf(fp, "<ul>\n");
  608.         if (strcmp(about, "NONE")) {
  609.  
  610.  
  611. #ifdef RISCOS
  612.  
  613.              fprintf(fp, "<li> <b><a href=\"file://%s/%s\">About this ", HOST, about);
  614.              fprintf(fp, "program</a></b>\n");
  615.  
  616. #else
  617.  
  618.              fprintf(fp, "<li> <b><a href=\"%s\">About this ", about);
  619.              fprintf(fp, "archive</a></b>\n");
  620. #endif
  621.         }
  622.         if (!reverse)
  623.                 fprintf(fp,
  624.                 "<li> <b><a href=\"#end\">Most recent messages</a></b>\n");
  625.         fprintf(fp, "<li> <b>Messages sorted by:</b> ");
  626.         fprintf(fp, "<a href=\"%s#start\">[ thread ]</a>", thrdname);
  627.         fprintf(fp, "<a href=\"%s#start\">[ subject ]</a>", subjname);
  628.         fprintf(fp, "<a href=\"%s#start\">[ author ]</a>\n", authname);
  629.         if (strcmp(archives, "NONE")) {
  630.                 fprintf(fp, "<li> <b><a href=\"%s\">Other mail ", archives);
  631.                 fprintf(fp, "archives</a></b>\n");
  632.         }
  633.         fprintf(fp, "</b>\n</ul>\n<p>\n");
  634.         fprintf(fp, "<b>Starting:</b> <i>%s</i><br>\n",
  635.         getdatestr(firstdatenum));
  636.         fprintf(fp, "<b>Ending:</b> <i>%s</i><br>\n", getdatestr(lastdatenum));
  637.         fprintf(fp, "<b>Messages:</b> %d\n<p>\n", bignum + 1);
  638.         fprintf(fp, "<ul>\n");
  639.  
  640.         printdates(fp, datelist);
  641.  
  642.         fprintf(fp, "</ul>\n<p>\n");
  643.         fprintf(fp, "<a name=\"end\"><b>Last message date:</b></a> ");
  644.         fprintf(fp, "<i>%s</i><br>\n", getdatestr(lastdatenum));
  645.         fprintf(fp, "<b>Archived on:</b> <i>%s</i><p>\n", getlocaltime());
  646.         fprintf(fp, "<ul>\n");
  647.         fprintf(fp, "<li> <b>Messages sorted by:</b> ");
  648.         fprintf(fp, "<a href=\"%s#start\">[ thread ]</a>", thrdname);
  649.         fprintf(fp, "<a href=\"%s#start\">[ subject ]</a>", subjname);
  650.         fprintf(fp, "<a href=\"%s#start\">[ author ]</a>\n", authname);
  651.         if (strcmp(archives, "NONE")) {
  652.                 fprintf(fp, "<li> <b><a href=\"%s\">Other mail ", archives);
  653.                 fprintf(fp, "archives</a></b>\n");
  654.         }
  655.         fprintf(fp, "</a></b>\n</ul>\n<p>\n");
  656.         printfooter(fp);
  657.         fclose(fp);
  658.  
  659.         if (newfile && chmod(filename, filemode) == -1) {
  660.                 sprintf(errmsg, "Couldn't chmod \"%s\" to %o.", filename,
  661.                 filemode);
  662.                 progerr(NULL);
  663.         }
  664.  
  665.         if (showprogress)
  666.                 putchar('\n');
  667.  
  668.  
  669. #ifdef RISCOS
  670.     osfile_set_type (filename,FILETYPE);
  671. #endif
  672.  }
  673.  
  674. /* Write the thread index...
  675. */
  676.  
  677. void writethreads(dir, label, archives, about)
  678.      char *dir;
  679.      char *label;
  680.      char *archives;
  681.      char *about;
  682. {
  683.         int newfile;
  684.         char filename[MAXFILELEN];
  685.         FILE *fp;
  686.  
  687.         printedlist = NULL;
  688.  
  689.  
  690. #ifdef RISCOS
  691.  
  692.         sprintf(filename, "%s.%s", INDEXDIR,thrdname);
  693.  
  694. #else
  695.         sprintf(filename, "%s%s%s", dir,
  696.         (dir[strlen(dir) - 1] == '/') ? "" : "/", thrdname);
  697. #endif
  698.  
  699.  
  700.         if (isfile(filename))
  701.                 newfile = 0;
  702.         else
  703.                 newfile = 1;
  704.         if ((fp = fopen(filename, "w")) == NULL) {
  705.                 sprintf(errmsg, "Couldn't write B \"%s\".", filename);
  706.                 progerr(NULL);
  707.         }
  708.  
  709.         if (showprogress)
  710.                 printf("Writing thread index to \"%s\"...", filename);
  711.  
  712.         fprintf(fp, "<title>%s by thread</title>\n", label);
  713.         fprintf(fp, "<a name=\"start\"><h1>%s by thread</h1></a>\n", label);
  714.         fprintf(fp, "<ul>\n");
  715.         if (strcmp(about, "NONE")) {
  716.  
  717.  
  718. #ifdef RISCOS
  719.                 fprintf(fp, "<li> <b><a href=\"file://%s/%s\">About this ", HOST, about);
  720.                 fprintf(fp, "program</a></b>\n");
  721. #else
  722.                 fprintf(fp, "<li> <b><a href=\"%s\">About this ", about);
  723.                 fprintf(fp, "archive</a></b>\n");
  724. #endif
  725.         }
  726.         if (!reverse)
  727.                 fprintf(fp,
  728.                 "<li> <b><a href=\"#end\">Most recent messages</a></b>\n");
  729.         fprintf(fp, "<li> <b>Messages sorted by:</b> ");
  730.         fprintf(fp, "<a href=\"%s#start\">[ date ]</a>", datename);
  731.         fprintf(fp, "<a href=\"%s#start\">[ subject ]</a>", subjname);
  732.         fprintf(fp, "<a href=\"%s#start\">[ author ]</a>\n", authname);
  733.         if (strcmp(archives, "NONE")) {
  734.                 fprintf(fp, "<li> <b><a href=\"%s\">Other mail ", archives);
  735.                 fprintf(fp, "archives</a></b>\n");
  736.         }
  737.         fprintf(fp, "</ul>\n<p>\n");
  738.         fprintf(fp, "<b>Starting:</b> <i>%s</i><br>\n",
  739.         getdatestr(firstdatenum));
  740.         fprintf(fp, "<b>Ending:</b> <i>%s</i><br>\n", getdatestr(lastdatenum));
  741.         fprintf(fp, "<b>Messages:</b> %d\n<p>\n", bignum + 1);
  742.         fprintf(fp, "<ul>\n");
  743.  
  744.         printthreads(fp, datelist);
  745.  
  746.         fprintf(fp, "</ul>\n<p>\n");
  747.         fprintf(fp, "<a name=\"end\"><b>Last message date:</b></a> ");
  748.         fprintf(fp, "<i>%s</i><br>\n", getdatestr(lastdatenum));
  749.         fprintf(fp, "<b>Archived on:</b> <i>%s</i><p>\n", getlocaltime());
  750.         fprintf(fp, "<ul>\n");
  751.         fprintf(fp, "<li> <b>Messages sorted by:</b> ");
  752.         fprintf(fp, "<a href=\"%s#start\">[ date ]</a>", datename);
  753.         fprintf(fp, "<a href=\"%s#start\">[ subject ]</a>", subjname);
  754.         fprintf(fp, "<a href=\"%s#start\">[ author ]</a>\n", authname);
  755.         if (strcmp(archives, "NONE")) {
  756.                 fprintf(fp, "<li> <b><a href=\"%s\">Other mail ", archives);
  757.                 fprintf(fp, "archives</a></b>\n");
  758.         }
  759.         fprintf(fp, "</ul>\n<p>\n");
  760.         printfooter(fp);
  761.         fclose(fp);
  762.  
  763.         if (newfile && chmod(filename, filemode) == -1) {
  764.                 sprintf(errmsg, "Couldn't chmod \"%s\" to %o.", filename,
  765.                 filemode);
  766.                 progerr(NULL);
  767.         }
  768.  
  769.         if (showprogress)
  770.                 putchar('\n');
  771. #ifdef RISCOS
  772.     osfile_set_type (filename,FILETYPE);
  773. #endif
  774.  }
  775.  
  776. /* Prints the article pointers in the thread index by date.
  777. */
  778.  
  779. void printthreads(fp, hp)
  780.      FILE *fp;
  781.      struct header *hp;
  782. {
  783.         int hasreply;
  784.         struct reply *rp;
  785.  
  786.         if (hp != NULL) {
  787.                 printthreads(fp, hp->left);
  788.  
  789.                 for (hasreply = 0, rp = replylist; rp != NULL; rp = rp->next)
  790.                         if (rp->frommsgnum == hp->msgnum) {
  791.                                 hasreply = 1;
  792.                                 break;
  793.                         }
  794.  
  795.                 if (!hasreply && !wasprinted(printedlist, hp->msgnum)) {
  796. #ifdef RISCOS
  797.  
  798.                 fprintf(fp, "<li> <a href=\"file://%s/%s/%.4d/%.4d\"><b>%s</b></a> ",
  799.                 HOST, FILEDIR, (hp->msgnum)/FPD,
  800.                 hp->msgnum, convchars(hp->subject));
  801.  
  802. #else
  803.  
  804.                         fprintf(fp, "<li> <a href=\"%.4d.html\"><b>%s</b></a> ",
  805.                         hp->msgnum, convchars(hp->subject));
  806. #endif
  807.  
  808.  
  809.                         fprintf(fp, "<a name=\"%d\"><i>%s</i></a>\n",
  810.                         hp->msgnum, hp->name);
  811.                         printedlist = (struct printed *)
  812.                         markasprinted(printedlist, hp->msgnum);
  813.  
  814.                         checkreplies(fp, hp->msgnum, 1);
  815.                 }
  816.  
  817.                 printthreads(fp, hp->right);
  818.         }
  819. }
  820.  
  821. /* Prints the subject index.
  822. */
  823.  
  824. void writesubjects(dir, label, archives, about)
  825.      char *dir;
  826.      char *label;
  827.      char *archives;
  828.      char *about;
  829. {
  830.         int newfile;
  831.         char filename[MAXFILELEN];
  832.         FILE *fp;
  833.  
  834. #ifdef RISCOS
  835.  
  836.         sprintf(filename, "%s.%s", INDEXDIR,subjname);
  837. #else
  838.  
  839.         sprintf(filename, "%s%s%s", dir,
  840.         (dir[strlen(dir) - 1] == '/') ? "" : "/", subjname);
  841. #endif
  842.  
  843.  
  844.  
  845.  
  846.  
  847.         if (isfile(filename))
  848.                 newfile = 0;
  849.         else
  850.                 newfile = 1;
  851.         if ((fp = fopen(filename, "w")) == NULL) {
  852.                 sprintf(errmsg, "Couldn't write C \"%s\".", filename);
  853.                 progerr(NULL);
  854.         }
  855.  
  856.         if (showprogress)
  857.                 printf("Writing subject index to \"%s\"...", filename);
  858.  
  859.         fprintf(fp, "<title>%s by subject</title>\n", label);
  860.         fprintf(fp, "<a name=\"start\"><h1>%s by subject</h1></a>\n", label);
  861.         fprintf(fp, "<ul>\n");
  862.         if (strcmp(about, "NONE")) {
  863.  
  864. #ifdef RISCOS
  865.                 fprintf(fp, "<li> <b><a href=\"file://%s/%s\">About this ",HOST,  about);
  866.                 fprintf(fp, "program</a></b>\n");
  867. #else
  868.                 fprintf(fp, "<li> <b><a href=\"%s\">About this ", about);
  869.                 fprintf(fp, "archive</a></b>\n");
  870. #endif
  871.         }
  872.         fprintf(fp, "<li> <b>Messages sorted by:</b> ");
  873.         fprintf(fp, "<a href=\"%s#start\">[ date ]</a>", datename);
  874.         fprintf(fp, "<a href=\"%s#start\">[ thread ]</a>", thrdname);
  875.         fprintf(fp, "<a href=\"%s#start\">[ author ]</a>\n", authname);
  876.         if (strcmp(archives, "NONE")) {
  877.                 fprintf(fp, "<li> <b><a href=\"%s\">Other mail ", archives);
  878.                 fprintf(fp, "archives</a></b>\n");
  879.         }
  880.         fprintf(fp, "</ul>\n<p>\n");
  881.         fprintf(fp, "<b>Starting:</b> <i>%s</i><br>\n",
  882.         getdatestr(firstdatenum));
  883.         fprintf(fp, "<b>Ending:</b> <i>%s</i><br>\n", getdatestr(lastdatenum));
  884.         fprintf(fp, "<b>Messages:</b> %d\n<p>\n", bignum + 1);
  885.         fprintf(fp, "<ul>\n");
  886.  
  887.         printsubjects(fp, subjectlist);
  888.  
  889.         fprintf(fp, "</ul>\n<p>\n");
  890.         fprintf(fp, "<b>Last message date:</b> <i>%s</i><br>\n",
  891.         getdatestr(lastdatenum));
  892.         fprintf(fp, "<b>Archived on:</b> <i>%s</i><p>\n", getlocaltime());
  893.         fprintf(fp, "<ul>\n");
  894.         fprintf(fp, "<li> <b>Messages sorted by:</b> ");
  895.         fprintf(fp, "<a href=\"%s#start\">[ date ]</a>", datename);
  896.         fprintf(fp, "<a href=\"%s#start\">[ thread ]</a>", thrdname);
  897.         fprintf(fp, "<a href=\"%s#start\">[ author ]</a>\n", authname);
  898.         if (strcmp(archives, "NONE")) {
  899.                 fprintf(fp, "<li> <b><a href=\"%s\">Other mail ", archives);
  900.                 fprintf(fp, "archives</a></b>\n");
  901.         }
  902.         fprintf(fp, "</ul>\n<p>\n");
  903.         printfooter(fp);
  904.         fclose(fp);
  905.  
  906.         if (newfile && chmod(filename, filemode) == -1) {
  907.                 sprintf(errmsg, "Couldn't chmod \"%s\" to %o.", filename,
  908.                 filemode);
  909.                 progerr(NULL);
  910.         }
  911.  
  912.         if (showprogress)
  913.                 putchar('\n');
  914. #ifdef RISCOS
  915.     osfile_set_type (filename,FILETYPE);
  916. #endif
  917.  }
  918.  
  919. /* Pretty-prints the dates in the index files.
  920. */
  921.  
  922. void printdates(fp, hp)
  923.      FILE *fp;
  924.      struct header *hp;
  925. {
  926.         if (hp != NULL) {
  927.                 printdates(fp, hp->left);
  928.  
  929. #ifdef RISCOS
  930.  
  931.                 fprintf(fp, "<li> <a href=\"file://%s/%s/%.4d/%.4d\"><b>%s</b></a> ",
  932.                 HOST, FILEDIR, (hp->msgnum)/FPD,
  933.                 hp->msgnum, convchars(hp->subject));
  934.  
  935. #else
  936.  
  937.                 fprintf(fp, "<li> <a href=\"%.4d.html\"><b>%s</b></a> ",
  938.                 hp->msgnum, convchars(hp->subject));
  939. #endif
  940.  
  941.                 fprintf(fp, "<a name=\"%d\"><i>%s</i></a>\n", hp->msgnum,
  942.                 hp->name);
  943.                 printdates(fp, hp->right);
  944.         }
  945. }
  946.  
  947. /* Print the subject index pointers alphabetically.
  948. */
  949.  
  950. void printsubjects(fp, hp)
  951.      FILE *fp;
  952.      struct header *hp;
  953. {
  954.         static char oldsubject[SUBJSTRLEN];
  955.  
  956.         if (hp != NULL) {
  957.                 printsubjects(fp, hp->left);
  958. #ifdef RISCOS
  959.                 if (strcmp(hp->subject, oldsubject))
  960. #else
  961.                 if (strcasecmp(hp->subject, oldsubject))
  962. #endif
  963.                         fprintf(fp, "<li> <b>%s</b>\n",
  964.                         convchars(hp->subject));
  965.                 fprintf(fp, "<ul>\n");
  966.  
  967. #ifdef RISCOS
  968.  
  969.                 fprintf(fp, "<li> <a href=\"file://%s/%s/%.4d/%.4d\">%s</a> ",
  970.                 HOST, FILEDIR, (hp->msgnum)/FPD,
  971.                 hp->msgnum, hp->name);
  972.  
  973. #else
  974.  
  975.                 fprintf(fp, "<li> <a href=\"%.4d.html\">%s</a> ",
  976.                 hp->msgnum, hp->name);
  977. #endif
  978.  
  979.                 fprintf(fp, "<a name=\"%d\"><i>%s</i></a>\n", hp->msgnum,
  980.                 hp->datestr);
  981.                 fprintf(fp, "</ul>\n");
  982.                 strcpy(oldsubject, hp->subject);
  983.                 printsubjects(fp, hp->right);
  984.         }
  985. }
  986.  
  987. /* Prints the author index file.
  988. */
  989.  
  990. void writeauthors(dir, label, archives, about)
  991.      char *dir;
  992.      char *label;
  993.      char *archives;
  994.      char *about;
  995. {
  996.         int newfile;
  997.         char filename[MAXFILELEN];
  998.         FILE *fp;
  999.  
  1000. #ifdef RISCOS
  1001.  
  1002.         sprintf(filename, "%s.%s", INDEXDIR,authname);
  1003.  
  1004. #else
  1005.  
  1006.         sprintf(filename, "%s%s%s", dir,
  1007.         (dir[strlen(dir) - 1] == '/') ? "" : "/", authname);
  1008. #endif
  1009.  
  1010.  
  1011.  
  1012.         if (isfile(filename))
  1013.                 newfile = 0;
  1014.         else
  1015.                 newfile = 1;
  1016.         if ((fp = fopen(filename, "w")) == NULL) {
  1017.                 sprintf(errmsg, "Couldn't write D \"%s\".", filename);
  1018.                 progerr(NULL);
  1019.         }
  1020.  
  1021.         if (showprogress)
  1022.                 printf("Writing author index to \"%s\"...", filename);
  1023.  
  1024.         fprintf(fp, "<title>%s by author</title>\n", label);
  1025.         fprintf(fp, "<a name=\"start\"><h1>%s by author</h1></a>\n", label);
  1026.         fprintf(fp, "<ul>\n");
  1027.         if (strcmp(about, "NONE")) {
  1028.  
  1029. #ifdef RISCOS
  1030.                 fprintf(fp, "<li> <b><a href=\"file://%s/%s\">About this ",HOST, about);
  1031.                 fprintf(fp, "program</a></b>\n");
  1032. #else
  1033.                 fprintf(fp, "<li> <b><a href=\"%s\">About this ", about);
  1034.                 fprintf(fp, "archive</a></b>\n");
  1035. #endif
  1036.         }
  1037.         fprintf(fp, "<li> <b>Messages sorted by:</b> ");
  1038.         fprintf(fp, "<a href=\"%s#start\">[ date ]</a>", datename);
  1039.         fprintf(fp, "<a href=\"%s#start\">[ thread ]</a>", thrdname);
  1040.         fprintf(fp, "<a href=\"%s#start\">[ subject ]</a>\n", subjname);
  1041.         if (strcmp(archives, "NONE")) {
  1042.                 fprintf(fp, "<li> <b><a href=\"%s\">Other mail ", archives);
  1043.                 fprintf(fp, "archives</a></b>\n");
  1044.         }
  1045.         fprintf(fp, "</ul>\n<p>\n");
  1046.         fprintf(fp, "<b>Starting:</b> <i>%s</i><br>\n",
  1047.         getdatestr(firstdatenum));
  1048.         fprintf(fp, "<b>Ending:</b> <i>%s</i><br>\n", getdatestr(lastdatenum));
  1049.         fprintf(fp, "<b>Messages:</b> %d\n<p>\n", bignum + 1);
  1050.         fprintf(fp, "<ul>\n");
  1051.  
  1052.         printauthors(fp, authorlist);
  1053.  
  1054.         fprintf(fp, "</ul>\n<p>\n");
  1055.         fprintf(fp, "<b>Last message date:</b> <i>%s</i><br>\n",
  1056.         getdatestr(lastdatenum));
  1057.         fprintf(fp, "<b>Archived on:</b> <i>%s</i><p>\n", getlocaltime());
  1058.         fprintf(fp, "<ul>\n");
  1059.         fprintf(fp, "<li> <b>Messages sorted by:</b> ");
  1060.         fprintf(fp, "<a href=\"%s#start\">[ date ]</a>", datename);
  1061.         fprintf(fp, "<a href=\"%s#start\">[ thread ]</a>", thrdname);
  1062.         fprintf(fp, "<a href=\"%s#start\">[ subject ]</a>\n", subjname);
  1063.         if (strcmp(archives, "NONE")) {
  1064.                 fprintf(fp, "<li> <b><a href=\"%s\">Other mail ", archives);
  1065.                 fprintf(fp, "archives</a></b>\n");
  1066.         }
  1067.         fprintf(fp, "</ul>\n<p>\n");
  1068.         printfooter(fp);
  1069.         fclose(fp);
  1070.  
  1071.         if (newfile && chmod(filename, filemode) == -1) {
  1072.                 sprintf(errmsg, "Couldn't chmod \"%s\" to %o.", filename,
  1073.                 filemode);
  1074.                 progerr(NULL);
  1075.         }
  1076.  
  1077.         if (showprogress)
  1078.                 putchar('\n');
  1079.  
  1080. #ifdef RISCOS
  1081.     osfile_set_type (filename,FILETYPE);
  1082. #endif
  1083.  }
  1084.  
  1085. /* Prints the author index links sorted alphabetically.
  1086. */
  1087.  
  1088. void printauthors(fp, hp)
  1089.      FILE *fp;
  1090.      struct header *hp;
  1091. {
  1092.         static char oldname[SUBJSTRLEN];
  1093.  
  1094.         if (hp != NULL) {
  1095.  
  1096. #ifdef RISCOS
  1097.                 printauthors(fp, hp->left);
  1098.                 if (strcmp(hp->name, oldname))
  1099.                         fprintf(fp, "<li> <b>%s</b>\n", hp->name);
  1100.                 fprintf(fp, "<ul>\n");
  1101.                 fprintf(fp, "<li> <a href=\"file://%s/%s/%.4d/%.4d\">%s</a> ",
  1102.                 HOST, FILEDIR, (hp->msgnum)/FPD,
  1103.                 hp->msgnum, convchars(hp->subject));
  1104. #else
  1105.                 printauthors(fp, hp->left);
  1106.                 if (strcasecmp(hp->name, oldname))
  1107.                         fprintf(fp, "<li> <b>%s</b>\n", hp->name);
  1108.                 fprintf(fp, "<ul>\n");
  1109.                 fprintf(fp, "<li> <a href=\"%.4d.html\">%s</a> ",
  1110.                 hp->msgnum, convchars(hp->subject));
  1111.  
  1112. #endif
  1113.  
  1114.                 fprintf(fp, "<a name=\"%d\"><i>%s</i></a>\n", hp->msgnum,
  1115.                 hp->datestr);
  1116.                 fprintf(fp, "</ul>\n");
  1117.                 strcpy(oldname, hp->name);
  1118.                 printauthors(fp, hp->right);
  1119.         }
  1120. }
  1121.  
  1122. /* While printing the thread index, prints any replies to replies.
  1123. */
  1124.  
  1125. void checkreplies(fp, num, level)
  1126.      FILE *fp;
  1127.      int num;
  1128.      int level;
  1129. {
  1130.         struct reply *rp;
  1131.  
  1132.         for (rp = replylist; rp != NULL; rp = rp->next)
  1133.                 if (rp->msgnum == num) {
  1134.                         if (level < thrdlevels)
  1135.                                 fprintf(fp, "<ul>\n");
  1136.  
  1137. #ifdef RISCOS
  1138.                         fprintf(fp, "<li> <a href=\"file://%s/%s/%.4d/%.4d\">",
  1139.                         HOST, FILEDIR, (rp->frommsgnum)/FPD,
  1140.                         rp->frommsgnum);
  1141. #else
  1142.                         fprintf(fp, "<li> <a href=\"%.4d.html\">",
  1143.                         rp->frommsgnum);
  1144. #endif
  1145.  
  1146.                       printedlist = (struct printed *)
  1147.                         markasprinted(printedlist, rp->frommsgnum);
  1148.                         fprintf(fp, "<b>%s </b></a> ",
  1149.                         convchars(rp->subject));
  1150.                         fprintf(fp, "<a name=\"%d\"><i>%s</i></a>\n",
  1151.                         rp->frommsgnum, rp->name);
  1152.                         checkreplies(fp, rp->frommsgnum, level + 1);
  1153.                         if (level < thrdlevels)
  1154.                                 fprintf(fp, "</ul>\n");
  1155.                 }
  1156. }
  1157.  
  1158. /* Prints a comment in the file.
  1159. */
  1160.  
  1161. void printcomment(fp, label, value)
  1162.      FILE *fp;
  1163.      char *label;
  1164.      char *value;
  1165. {
  1166.         fprintf(fp, "<!-- %s=\"%s\" -->\n", label, value);
  1167. }
  1168.  
  1169. /* Prints the footer and pointer to the docs in the index files.
  1170. */
  1171.  
  1172. void printfooter(fp)
  1173.      FILE *fp;
  1174. {
  1175.         fprintf(fp, "<hr>\n<i>This archive was generated by ");
  1176.         fprintf(fp, "<a href=\"%s\">%s %s</a>.</i>\n",
  1177.         HMURL, PROGNAME, VERSION);
  1178. }
  1179.  
  1180. /* Prints a program error string and stops. If errorstr is NULL,
  1181. ** this prints whatever happens to be in errstr[] at the time.
  1182. */
  1183.  
  1184. void progerr(errorstr)
  1185.      char *errorstr;
  1186. {
  1187.         if (errorstr != NULL)
  1188.                 fprintf(stderr, "%s: %s\n", PROGNAME, errorstr);
  1189.         else
  1190.                 fprintf(stderr, "%s: %s\n", PROGNAME, errmsg);
  1191.         fprintf(stderr, "%s: type \"%s -z\" for options.\n", PROGNAME,
  1192.         PROGNAME);
  1193.         exit(-1);
  1194. }
  1195.  
  1196. /* Prints the usage.
  1197. */
  1198.  
  1199. void usage()
  1200. {
  1201.         printf("  usage: %s -upix [-m \"mbox\"] [-l \"label\"] ",
  1202.         PROGNAME);
  1203.         printf("[-d \"dir\"]\n");
  1204.         printf("         [-a \"URL\"] [-b \"URL\"] [-c \"file\"]\n\n");
  1205.         printf("options: -u : Update archive by one article\n");
  1206.         printf("         -p : Show progress\n");
  1207.         printf("         -i : Read messages from standard input\n");
  1208.         printf("         -x : Overwrite previous messages\n");
  1209.         printf("         -m : Mail archive to read in\n");
  1210.         printf("         -l : What to name the output archive\n");
  1211.         printf("         -d : The directory to save HTML files in\n");
  1212.         printf("         -a : URL to other archives\n");
  1213.         printf("         -b : URL to archive information\n");
  1214.         printf("         -c : Configuration file to read in\n\n");
  1215.         printf("version: %s\n", VERSION);
  1216.         printf("   docs: %s\n", HMURL);
  1217.  
  1218.         exit(1);
  1219. }
  1220.